<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Date - 生成随机时间</title>
</head>

<body>
    <script src="https://cdn.bootcdn.net/ajax/libs/Mock.js/1.0.1-beta3/mock-min.js"></script>
    <div class="box">
        展示内容:<div id="content"></div>
    </div>
    <script>
        let Random = Mock.Random;

        let list = Mock.mock({

            //随机日期字符串
            date_1: Random.date(),
            // => "2002-10-23"
            date_2: Random.date('yyyy-MM-dd'),
            // => "1983-01-29"
            date_3: Random.date('yy-MM-dd'),
            // => "79-02-14"
            date_4: Random.date('y-MM-dd'),
            // => "81-05-17"
            date_5: Random.date('y-M-d'),
            // => "84-6-5"

            //随机时间字符串
            time_1: Random.time(),
            // => "00:14:47"
            time_2: Random.time('A HH:mm:ss'),
            // => "PM 20:47:37"
            time_3: Random.time('a HH:mm:ss'),
            // => "pm 17:40:00"
            time_4: Random.time('HH:mm:ss'),
            // => "03:57:53"
            time_5: Random.time('H:m:s'),
            // => "3:5:13"

            //随机日期和时间字符串
            datetime_1: Random.datetime(),
            // => "1977-11-17 03:50:15"
            datetime_2: Random.datetime('yyyy-MM-dd A HH:mm:ss'),
            // => "1976-04-24 AM 03:48:25"
            datetime_3: Random.datetime('yy-MM-dd a HH:mm:ss'),
            // => "73-01-18 pm 22:12:32"
            datetime_4: Random.datetime('y-MM-dd HH:mm:ss'),
            // => "79-06-24 04:45:16"
            datetime_5: Random.datetime('y-M-d H:m:s'),
            // => "02-4-23 2:49:40"

            //当前日期和时间字符串
            now_1: Random.now(),
            // => "2014-04-29 20:08:38 "
            now_2: Random.now('day', 'yyyy-MM-dd HH:mm:ss SS'),
            // => "2014-04-29 00:00:00 000"
            now_3: Random.now('day'),
            // => "2014-04-29 00:00:00 "
            now_4: Random.now('yyyy-MM-dd HH:mm:ss SS'),
            // => "2014-04-29 20:08:38 157"

            now_5: Random.now('year'),
            // => "2014-01-01 00:00:00"
            now_6: Random.now('month'),
            // => "2014-04-01 00:00:00"
            now_7: Random.now('week'),
            // => "2014-04-27 00:00:00"
            now_8: Random.now('day'),
            // => "2014-04-29 00:00:00"
            now_9: Random.now('hour'),
            // => "2014-04-29 20:00:00"
            now_10: Random.now('minute'),
            // => "2014-04-29 20:08:00"
            now_11: Random.now('second'),
            // => "2014-04-29 20:08:38"



        })

        //展示数据
        console.table(list)
        x = document.getElementById("content");
        //将对象转为JSON
        x.innerHTML = JSON.stringify(list, null, '<br />');

    </script>

</body>

</html>